#if !defined(ximera_physics_ode_entity_hpp)
#define ximera_physics_ode_entity_hpp

// -----------------------------------------------------------

#include <ximera/physics/ientity.hpp>
#include <ximera/physics/ode/ode.hpp>
#include <ximera/common/sharedptr.hpp>
#include <ximera/physics/ode/rigidbody.hpp>

#include <vector>

namespace ximera { namespace physics { namespace ode
{
    class Space;

    class XIMERA_PLUGIN_API Entity : public IEntity
    {
    public:
        Entity(Space* space, EntityType type = EntityType::Dynamic);
        virtual	~Entity();

        virtual EntityType type() const;

        virtual ISpace* space() const;

        virtual IRigidBody* body() const;

        virtual UInt32 shapeCount() const;
        virtual IShape* shape(UInt32 index) const;

        virtual void addShape(IShape* shape);
        virtual void removeShape(IShape* shape);
        virtual void removeAllShapes();

        virtual IShape* createShape(ShapeType type);

        Space* odeSpace() const { return _space; }
        RigidBody* odeBody() const { return _body.get(); }
        void attach(Space* space);
        void detach();

    private:
        typedef std::vector<IShape*> ShapeContainer;

        Space* _space;
        EntityType _type;
        ShapeContainer _shapes;
        SharedPtr<RigidBody> _body;

        static SharedPtr<ShapeFactory> _shapeFactory;
    };
}}}

// -----------------------------------------------------------

#endif
